/*
 * @Description:
 * @Version: V1.0.0
 * @Author: 周艳凯 484894717@qq.com
 * @Date: 2024-10-09 10:09:19
 * @LastEditors: 周艳凯 484894717@qq.com
 * @LastEditTime: 2024-10-25 18:04:17
 * @FilePath: eslint.config.mjs
 * Copyright 2024 Marvin, All Rights Reserved.
 * 2024-10-09 10:09:19
 */
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginVue from "eslint-plugin-vue";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";

export default [
  {
    // 配置需要被忽略的文件，替代之前的 .eslintignore 文件
    ignores: ["**/dist/", "src/tmui/", "node_modules", "docs/"],
  },
  {
    files: ["**/*.{js,mjs,cjs,ts,vue}"],
  },
  {
    languageOptions: {
      globals: {
        ...globals.browser,
        ...globals.node,
        uni: "writable",
      },
    },
  },
  /** js推荐配置 */
  pluginJs.configs.recommended,
  /** ts推荐配置 */
  ...tseslint.configs.recommended,
  /** vue推荐配置 */
  ...pluginVue.configs["flat/recommended"],
  eslintPluginPrettierRecommended,
  /**
   * vue 规则
   */
  {
    files: ["**/*.vue"],
    languageOptions: {
      parserOptions: { parser: tseslint.parser },
    },
    // "off"或者 - 关闭规则0
    // "warn"或者 - 将规则作为警告打开（不影响退出代码）1
    // "error"或者 - 将规则作为错误打开（退出代码将为 1）2
    rules: {
      // vue
      "vue/multi-word-component-names": 0,
      "no-async-promise-executor": 0,
    },
  },
  /**
   * typescript 规则
   */
  {
    files: ["**/*.{ts,tsx,vue}"],
    rules: {
      "@typescript-eslint/no-explicit-any": "off",
      "@typescript-eslint/no-empty-object-type": "off",
    },
  },
];
